package com.yx.frame.builder;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;

public class ServiceBuilder {

	protected Shell shell;

	/**
	 * Launch the application.
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			ServiceBuilder window = new ServiceBuilder();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents(display);
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents(Display display) {
		shell = new Shell(display, SWT.CLOSE | SWT.MIN);
		shell.setSize(1029, 621);
		shell.setText("云想科技ServiceBuilder - 用于自动生成后台服务");
		shell.setLayout(new RowLayout(SWT.HORIZONTAL));
		LeftControlTree LeftControlTree = new LeftControlTree(shell, SWT.NONE);
		MethodPublic MethodPublic = new MethodPublic(shell, SWT.NONE);
		MessageBox messageBox = new MessageBox(shell, SWT.OK);
		messageBox.setMessage("云想科技ServiceBuilder提示：\r\n\r\n1、为了降低JS文件大小和网络流量，方法命名和数据元素命名尽量不要过长。\r\n2、字段名setUser、getUser、serverUrl、IsOK、Message、isOK、message为保留字段在数据元素声明中不要使用。\r\n3、在同一RSB描述文件中函数不能重名，在设计中建议最好在所有文件中函数不要重名。\r\n4、注意方法ID，是在所有文件中不能重复并且从0开始的连续数字，用于唯一区分不同方法。");
		messageBox.open();
		shell.getChildren()[1].setVisible(false);
		shell.addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent e) {
				//System.exit(0);
			}
		});
		
	}
}
